﻿@model DroidClaim.Web.Models.SurveyorLocationModel

@{
    Layout = null;
}
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />    
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.20.min.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () { 

            $('.grid th').each(function () {
                if (this.innerHTML == "") {
                    this.innerHTML = "<input type='checkbox' id='chkHeader'  />";
                }
            });

            $('.grid th input:checkbox').click(function (e) {
                var table = $(e.target).closest('table');
                $('td input:checkbox', table).attr('checked', e.target.checked);
            });
        });

        function SetOpener(Id, Code, Name)
        {
            //alert(Id);
								window.opener.document.getElementById("Surveyor_SurveyorLocation").value = Id;
					window.opener.document.getElementById("Surveyor_SurveyorLocationCode").value = Code;
					window.opener.document.getElementById("Surveyor_SurveyorLocationName").value = Name;
				            window.close();
        }
    </script>  

<h2>SurveyorLocation</h2>
<body style="padding:10px 10px 10px 10px">
@{  
    if (Model.ListOfSurveyorLocation != null && Model.ListOfSurveyorLocation.Count > 0)
    {
        var grid = new WebGrid(
            source: Model.ListOfSurveyorLocation, canPage: false);
        @grid.GetHtml(
        tableStyle: "tableMain grid",
        rowStyle: "row-a",
        alternatingRowStyle: "row-b",
        columns: grid.Columns(          
          grid.Column(header: "Code", columnName: "Code", style: "width_10per"),
          grid.Column(header: "Name", style: "width_15per", columnName: "Name",
            format: item =>
            {
                string link = "<a href=\"#\" class=\"word_wrap\" onclick=\"SetOpener('{0}','{1}','{2}');\">{2}</a>";
                return Html.Raw(string.Format(link, item.Id, item.Code, item.Name));
            })

			                   , grid.Column(header: "Latitude", style: "width_100per", columnName: "Latitude",
						format: item =>
						{
							string Latitude = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(Latitude, String.IsNullOrWhiteSpace(item.Latitude+"") ? "" : item.Latitude));
						 })
                   , grid.Column(header: "Longitude", style: "width_100per", columnName: "Longitude",
						format: item =>
						{
							string Longitude = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(Longitude, String.IsNullOrWhiteSpace(item.Longitude+"") ? "" : item.Longitude));
						 })
                   , grid.Column(header: "Status", style: "width_100per", columnName: "Status",
						format: item =>
						{
							string Status = "<div class=\"word_wrap\">{0}</div>";
							return Html.Raw(string.Format(Status, String.IsNullOrWhiteSpace(item.Status+"") ? "" : item.Status));
						 })
			    
        ));
    }
    else
    {
    <div class="emptyRow">No item base on search criteria that you had inputed.</div>
    
    }
 }
</body>